export default function loadStaticData(filename) {
  if (!filename) {
    throw 'filename is required'
  }
  return new Promise((resolve, reject) => {
    plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function (fs) {
      fs.root.getFile(
        'cable/' + filename,
        {
          create: false,
        },
        function (fileEntry) {
          fileEntry.file(function (file) {
            var fileReader = new plus.io.FileReader()
            fileReader.readAsText(file, 'utf-8')
            fileReader.onloadend = function (evt) {
              const str = evt.target.result
              try {
                resolve(JSON.parse(str))
              } catch (error) {
                console.error(filename + '文件加载失败')
                reject(error)
              }
            }
          })
        }
      )
    })
  })
}
